<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<jsp:useBean id="categoryBean"
	class="by.grsu.bso.beans.CategoryUtilBean" scope="application" />
<jsp:useBean id="productBean" class="by.grsu.bso.beans.ProductUtilBean"
	scope="application" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<div class="layout-middle">
	<div class="sidebar">
		<strong class="sidebar-header">Книги</strong>

		<ul>

			<c:set var="parentCategory"
				value="${applicationScope.categoryBean.getParentCategory(param.category)}" />
			<c:set var="currentCategory"
				value="${applicationScope.categoryBean.getCategory(param.category)}" />

			<c:if test="${!empty parentCategory}">
				<a href="?category=${parentCategory.categoryId}">${parentCategory.name}</a> > ${currentCategory.name}
     </c:if>

			<c:set var="categories" value="${applicationScope.categoryBean.getCategories(param.category)}" />
			<c:forEach items="${categories}" var="category">
				<li><a href="?category=${category.categoryId}">${category.name}</a></li>
			</c:forEach>
		</ul>

	</div>
	<div class="content">

		<h2 align="center" style="margin: 4px 2px">Все книги</h2>
<!--  
		<div class="public-button-sort">
			<div>
				<form>
					<input type="submit" value="по цене" class="button-sort" />
				</form>
			</div>
			<div>
				<form>
					<input type="submit" value="по автору" class="button-sort" />
				</form>
			</div>
		</div>
-->	

		<c:set var="currentProduct" value="${applicationScope.productBean.getProducts(currentCategory.categoryId)}" />
		<c:forEach items="${currentProduct}" var="product">
			<div class="image-block-parameter">
				<div class="image-full-parameter">
					<a href="pages/product.jsp?product=${product.id}"><img src="${product.imageBase64}" class="image-parameter" /></a> 
					<a href="pages/product.jsp?product=${product.id}"><h5 class="image-pretext">${product.name}</h5></a>
					<br> <font class="image-text">
					 ${product.autor},
					${product.yearPublication}<br> ${product.price}руб.
					</font>
				</div>

			</div>

		</c:forEach>
		
	
	</div>

</div>